#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int heightChecker(int* heights, int heightsSize) 
{
    int ret = 0;
    int i = 0;
    int j = 0;
    int sum[100] = { 0 };
    for (i = 0; i < heightsSize; i++)
    {
        sum[i] = heights[i];
    }
    for (i = 0; i < heightsSize - 1; i++)
    {
        for (j = 0; j < heightsSize - 1 - i; j++)
        {
            if (sum[j] > sum[j + 1])
            {
                int mid = sum[j];
                sum[j] = sum[j + 1];
                sum[j + 1] = mid;
            }
        }
    }
    for (i = 0; i < heightsSize; i++)
    {
        if (heights[i] != sum[i])
            ret++;
    }
    return ret;
}
